package com.yt.product.service;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yt.product.common.config.YmlConfig;
import com.yt.product.mapper.ProductCategoryMapper;
import com.yt.product.models.bo.ProductCategorySaveBO;
import com.yt.product.models.dto.ProductCategoryDTO;
import com.yt.product.models.service.IProductCategoryService;
import com.yt.product.models.vo.ProductCategoryVO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * 产品类别信息控制器
 *
 * @author zhou
 * @Date 2025-09-05 11:32:07
 */
@DubboService
public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryMapper, ProductCategoryDTO> implements IProductCategoryService {

    @Resource
    private YmlConfig ymlConfig;

    @Override
    public boolean add(ProductCategorySaveBO saveBO) {
        ProductCategoryDTO dto = new ProductCategoryDTO();
        BeanUtils.copyProperties(saveBO, dto);
        Long id = ymlConfig.getPkId();
        dto.setId(id);
        return this.insert(dto);
    }

    @Override
    public List<ProductCategoryVO> queryPermission() {
        List<ProductCategoryVO> productCategoryVOS = baseMapper.query();
        return productCategoryVOS;
    }

}
